package cloudspace.vm.javassist.tests;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URL;

import _test.wrap.MyFile;

public class FileIOTranslatorTest extends JavassistTestCase
{
	String classToLoad = "_test.wrap.FileTestClass";

	public void setUp()
	{
		super.setUp();
	}

	// java.io.File(java.lang.String)
	public void testTranslateNormalFileWindows()
	{
		try
		{
			String methodToTest = "normalFile";
			String path = "C:/foo.bar";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { path });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("foo.bar", relativeUserView);
			assertEquals("/foo.bar", absUserView);
			assertEquals(realPath + "/foo.bar", relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}

	}

	public void testTranslateNormalFileWindows2()
	{
		try
		{
			String methodToTest = "normalFile";
			String path = "C:/users/foo.bar";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { path });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("users/foo.bar", relativeUserView);
			assertEquals("/users/foo.bar", absUserView);
			assertEquals(realPath + "/users/foo.bar", relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}

	}

	public void testTranslateNormalFile()
	{
		try
		{
			String methodToTest = "normalFile";
			String path = "file1";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { path });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("file1", relativeUserView);
			assertEquals("/file1", absUserView);
			assertEquals(realPath + "/file1", relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}

	}

	public void testConstructorString()
	{
		try
		{
			String methodToTest = "normalFile";

			String path = "";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { path });
			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("", relativeUserView);
			assertEquals("/", absUserView);
			assertEquals(realPath.substring(0, realPath.length()), relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testConstructorStringNull()
	{
		try
		{
			String methodToTest = "normalFile";
			String path = null;
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { path });
			assertNull(testFile);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(true);
		}
	}

	public void testSuperClassOverload()
	{
		try
		{
			String methodToTest = "superClassCallFile";

			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/foo/bar/file2", relativeUserView);
			assertEquals("/foo/bar/file2", absUserView);
			assertEquals(realPath + "/foo/bar/file2", relativePath);

		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File(java.lang.String,java.lang.String)
	public void testFileStringString1()
	{
		try
		{
			String methodToTest = "stringHeirarch";
			String param1 = "/parent/foo";
			String param2 = "/child/bar";

			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { String.class, String.class },
					new Object[] { param1, param2 });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/parent/foo/child/bar", relativeUserView);
			assertEquals("/parent/foo/child/bar", absUserView);
			assertEquals(realPath + "/parent/foo/child/bar", relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testFileStringString2()
	{
		try
		{
			String methodToTest = "stringHeirarch";
			String param1 = "parent/foo";
			String param2 = "child/bar";

			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { String.class, String.class },
					new Object[] { param1, param2 });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("parent/foo/child/bar", relativeUserView);
			assertEquals("/parent/foo/child/bar", absUserView);
			assertEquals(realPath + "/parent/foo/child/bar", relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testFileStringString3()
	{
		try
		{
			String methodToTest = "stringHeirarch";
			String param1 = null;
			String param2 = "child/bar";

			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { String.class, String.class },
					new Object[] { param1, param2 });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("child/bar", relativeUserView);
			assertEquals("/child/bar", absUserView);
			assertEquals(realPath + "/child/bar", relativePath);
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			assertTrue(false);
		}
	}

	public void testFileStringString4()
	{
		try
		{
			String methodToTest = "stringHeirarch";
			String param1 = "/parent/foo";
			String param2 = null;

			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { String.class, String.class },
					new Object[] { param1, param2 });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/parent/foo", relativeUserView);
			assertEquals("/parent/foo", absUserView);
			assertEquals(realPath + "/parent/foo", relativePath);
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			assertTrue(false);
		}
	}

	// java.io.File(URI)
	public void testURIFile()
	{
		try
		{
			String methodToTest = "uriFile";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/foo.bar", relativeUserView);
			assertEquals("/foo.bar", absUserView);
			assertEquals(realPath + "/foo.bar", relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File(java.io.File,java.lang.String)
	public void testFileStringConstructor1()
	{
		try
		{
			String methodToTest = "testFileStringConstructor";
			String param1 = "/parentPath/";
			String param2 = "/childPath";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class,
							java.lang.String.class }, new Object[] { param1,
							param2 });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/parentPath/childPath", relativeUserView);
			assertEquals("/parentPath/childPath", absUserView);
			assertEquals(realPath + "/parentPath/childPath", relativePath);

		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			assertTrue(false);
		}
	}

	public void testFileStringConstructor2()
	{
		try
		{
			String methodToTest = "testFileStringConstructor";
			String param1 = null;
			String param2 = "/childPath";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class,
							java.lang.String.class }, new Object[] { param1,
							param2 });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/childPath", relativeUserView);
			assertEquals("/childPath", absUserView);
			assertEquals(realPath + "/childPath", relativePath);

		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			assertTrue(false);
		}
	}

	public void testFileStringConstructor3()
	{
		try
		{
			String methodToTest = "testFileStringConstructor";
			String param1 = "/parentPath/";
			String param2 = null;
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class,
							java.lang.String.class }, new Object[] { param1,
							param2 });

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/parentPath/childPath", relativeUserView);
			assertEquals("/parentPath/childPath", absUserView);
			assertEquals(realPath + "/parentPath/childPath", relativePath);

		}
		catch (InvocationTargetException e)
		{
			// e.printStackTrace();
			assertTrue(true);
		}
	}

	public void testHeirarch1()
	{
		try
		{
			String methodToTest = "fileHeirarch1";
			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/parentPath/parentFile/childPath/childFile",
					relativeUserView);
			assertEquals("/parentPath/parentFile/childPath/childFile",
					absUserView);
			assertEquals(realPath
					+ "/parentPath/parentFile/childPath/childFile",
					relativePath);

		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testHeirarch2()
	{
		try
		{
			String methodToTest = "fileHeirarch2";

			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("childPath/childFile", relativeUserView);
			assertEquals("/childPath/childFile", absUserView);
			assertEquals(realPath + "/childPath/childFile", relativePath);
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			assertTrue(false);
		}
	}

	// java.io.File.equals
	public void testParamMethodOverload()
	{
		try
		{

			String methodToTest = "paramMethodOver";
			boolean testEquality = (Boolean) runMethod(classToLoad,
					methodToTest, new Class<?>[] {}, new Object[] {});
			assertTrue(testEquality);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.getAbsoluteFile()
	public void testGetAbsolute()
	{
		try
		{
			String methodToTest = "getAbsoluteFile";
			File absFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});

			String userViewPath = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) absFile });
			String absoluteUserPath = (String) runMethod(classToLoad,
					"askForAbsPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) absFile });
			assertEquals("/foo/bar", userViewPath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}

	}

	// java.io.File.getCanonicalFile()
	public void testGetCanonical()
	{
		try
		{
			String methodToTest = "getCanonicalFile";
			File absFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			assertNotNull(absFile);
			String userViewPath = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) absFile });
			assertEquals("/foo/bar", userViewPath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.getName()
	public void testGetName()
	{
		try
		{
			String methodToTest = "getName";
			String fileName = "/fakepath/foo.bar";
			String name = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { fileName });
			assertEquals("foo.bar", name);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testGetName2()
	{
		try
		{

			String methodToTest = "getName";
			String fileName = "/";
			String name = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { fileName });
			assertEquals("", name);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testGetName3()
	{
		try
		{

			String methodToTest = "getName";
			String fileName = "";
			String name = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { fileName });
			assertEquals("", name);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.getParent()
	public void testGetParent1()
	{
		try
		{
			String methodToTest = "getParent";
			String param = "foo/bar";
			String parentPath = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			assertNotNull(parentPath);
			assertEquals("foo", parentPath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testGetParent2()
	{
		try
		{
			String methodToTest = "getParent";
			String param = "";
			String parentPath = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			assertNull(parentPath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testGetParent3()
	{
		try
		{
			String methodToTest = "getParent";
			String param = "foo";
			String parentPath = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			assertNull(parentPath);
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			assertTrue(false);
		}
	}

	public void testGetParent4()
	{
		try
		{
			String methodToTest = "getParent";
			String param = "/";
			String parentPath = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			assertNull(parentPath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.getParentFile()
	public void testGetParentFile()
	{
		try
		{
			String methodToTest = "getParentFile";
			String param = "foo/bar";
			File parentFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			assertNotNull(parentFile);
			String userViewPath = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) parentFile });
			assertEquals("foo", userViewPath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.isAbsolute()
	public void testIsAbsolute1()
	{
		try
		{
			String methodToTest = "isAbsolute";
			String param = "foo";
			boolean absoluteBool = (Boolean) runMethod(classToLoad,
					methodToTest, new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			assertFalse(absoluteBool);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testIsAbsolute2()
	{
		try
		{
			String methodToTest = "isAbsolute";
			String param = "/foo";
			boolean absoluteBool = (Boolean) runMethod(classToLoad,
					methodToTest, new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			assertTrue(absoluteBool);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.list()
	public void testList()
	{
		try
		{
			String methodToTest = "listFiles";
			File[] testList = (File[]) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			for (int i = 0; i < testList.length; i++)
			{
				String userViewPath = (String) runMethod(classToLoad,
						"askForGetPath", new Class<?>[] { java.io.File.class },
						new Object[] { (Object) testList[i] });
				if (userViewPath.contains(realPath + "/"))
				{
					fail();
				}
			}
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.listFiles()
	public void testListAlt1()
	{
		try
		{
			String methodToTest = "listFilesAlt1";
			File[] testList = (File[]) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			for (int i = 0; i < testList.length; i++)
			{
				String userViewPath = (String) runMethod(classToLoad,
						"askForGetPath", new Class<?>[] { java.io.File.class },
						new Object[] { (Object) testList[i] });
				if (userViewPath.contains(realPath))
				{
					fail();
				}
			}
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testListAlt2()
	{
		try
		{
			String methodToTest = "listFilesAlt2";
			File[] testList = (File[]) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			for (int i = 0; i < testList.length; i++)
			{
				String userViewPath = (String) runMethod(classToLoad,
						"askForGetPath", new Class<?>[] { java.io.File.class },
						new Object[] { (Object) testList[i] });
				if (userViewPath.contains(realPath + "/"))
				{
					fail();
				}
			}
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	public void testListFiles()
	{
		try
		{
			String methodToTest = "listFiles";
			File[] testList = (File[]) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			for (int i = 0; i < testList.length; i++)
			{
				String userViewPath = (String) runMethod(classToLoad,
						"askForGetPath", new Class<?>[] { java.io.File.class },
						new Object[] { (Object) testList[i] });
				if (userViewPath.contains(realPath + "/"))
				{
					fail();
				}
			}
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}

	}

	// OverLoaded Get Path
	public void testOverloadedGetPathFile()
	{
		try
		{
			String methodToTest = "overloadedGetPathFile";

			File testFile = (File) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});

			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testFile });
			String relativePath = testFile.getPath();

			assertEquals("/fake/mustnotbeused/file3", relativeUserView);
			assertEquals("/fake/mustnotbeused/file3", absUserView);
			assertEquals(
					"/home/mjw87/workspace/cloudspace/src//fake/mustnotbeused/file3",
					relativePath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.listRoots()
	public void testListRoots()
	{
		try
		{
			String methodToTest = "listRoots";
			File[] testList = (File[]) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			assertEquals(testList.length, 1);
			assertEquals(testList[0].getPath(),
					"/home/mjw87/workspace/cloudspace/src");
			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) testList[0] });
			assertEquals("/", relativeUserView);
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			assertTrue(false);
		}
	}

	// java.io.File.toURI
	public void testToURI()
	{
		try
		{
			String methodToTest = "toURI";
			URI testURI = (URI) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			assertEquals("/test", testURI.getPath());
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.toURL
	public void testToURL()
	{
		try
		{
			String methodToTest = "toURL";
			URL testURL = (URL) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			assertEquals("file:/test/foo.bar", testURL.toString());
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.compareTo()
	public void testCompareTo()
	{
		try
		{
			String methodToTest = "testCompareTo";
			Integer compareInt = (Integer) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			assertEquals(compareInt, new Integer(0));
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// java.io.File.toString()
	public void testToString()
	{
		try
		{
			String methodToTest = "getToString";
			String stringPath = (String) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			assertNotNull(stringPath);
			assertEquals("/foo/bar", stringPath);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// Random Inheritance Tests
	public void testInherit()
	{
		try
		{
			String methodToTest = "testInherit";
			File[] realFiles = (File[]) runMethod(classToLoad, methodToTest,
					new Class<?>[] {}, new Object[] {});
			String relativeUserView = (String) runMethod(classToLoad,
					"askForGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) realFiles[0] });
			String absUserView = (String) runMethod(classToLoad,
					"askForCanGetPath", new Class<?>[] { java.io.File.class },
					new Object[] { (Object) realFiles[0] });

			assertEquals("/fake/test", relativeUserView);
			assertEquals("/fake/test", absUserView);
			relativeUserView = (String) runMethod(classToLoad, "askForGetPath",
					new Class<?>[] { java.io.File.class },
					new Object[] { (Object) realFiles[0] });
			absUserView = (String) runMethod(classToLoad, "askForCanGetPath",
					new Class<?>[] { java.io.File.class },
					new Object[] { (Object) realFiles[0] });

			assertEquals("/fake/test", relativeUserView);
			assertEquals("/fake/test", absUserView);
		}
		catch (InvocationTargetException e)
		{
			assertTrue(false);
		}
	}

	// This test is un needed cause list is not rewritten.
	public void testListString()
	{
		try
		{
			String methodToTest = "list";
			String param = "../";
			String[] paths = (String[]) runMethod(classToLoad, methodToTest,
					new Class<?>[] { java.lang.String.class },
					new Object[] { param });
			for (String path : paths)
			{
				if (path.startsWith(realPath))
				{
					fail();
				}
			}
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
			fail();
		}
	}

}
